﻿<%@ Page Language="C#" MasterPageFile="~/SiteWorx/ControlPanel.master" AutoEventWireup="true" CodeFile="SiteManager.aspx.cs" Inherits="SiteWorx_SiteManager" Theme="Admin"
    StylesheetTheme="Admin" Title="Site Manager" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Csla" Namespace="Csla.Web" TagPrefix="cc1" %>
<asp:Content ID="cntMain" ContentPlaceHolderID="cphMain" runat="Server">
    <telerik:RadAjaxPanel runat="server" ID="rapnlSiteManager" HorizontalAlign="NotSet"
        LoadingPanelID="ralSiteManager">
        <span class="siteWorxTitle">Site Manager</span>
        <table border="0">
            <tr>
                <td>
                    <telerik:RadToolBar ID="rtbPages" runat="server" Skin="Telerik" Width="717px" 
                        OnClientButtonClicked="toolbarSiteMainClicked" OnClientButtonClicking="toolbarSiteMainClicking" onbuttonclick="rtbPages_ButtonClick">
                        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                        <Items>
                            <telerik:RadToolBarButton runat="server" CausesValidation="False" PostBack="False"
                                Text="New Page" ImageUrl="~/SiteWorx/Images/newPage.gif" CommandName="CreateNewPage">
                            </telerik:RadToolBarButton>
                            <telerik:RadToolBarDropDown runat="server" ImageUrl="~/SiteWorx/Images/siteTheme.gif"
                                Text="Site Theme">
                            </telerik:RadToolBarDropDown>
                            <telerik:RadToolBarButton runat="server" CausesValidation="False" PostBack="False" Value="ViewSite"
                            Text="View Site" ImageUrl="~/SiteWorx/Images/viewSite.gif">
                            </telerik:RadToolBarButton>
                        </Items>
                    </telerik:RadToolBar>
                </td>
            </tr>
            <tr>
                <td>
                    <telerik:RadGrid ID="rgvPages" runat="server" Skin="Telerik" DataSourceID="cdsPageList"
                        AutoGenerateColumns="false" Width="715px" 
                        ondeletecommand="rgvPages_DeleteCommand" 
                        oneditcommand="rgvPages_EditCommand" onitemdatabound="rgvPages_ItemDataBound">
                        <HeaderContextMenu EnableTheming="True">
                            <CollapseAnimation Duration="200" Type="OutQuint" />
                        </HeaderContextMenu>
                        <MasterTableView>
                            <RowIndicatorColumn>
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn>
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="" UniqueName="Visibility">
                                    <ItemTemplate>
                                        <div class="<%# Eval("Visibility") %>" title="<%# Eval("Visibility") %>">
                                        </div>
                                        <asp:HiddenField runat="server" ID="hidPageId" Value='<%# Eval("ID") %>' />
                                        <asp:HiddenField runat="server" ID="hidPageFileName" Value='<%# Eval("FileName") %>' />
                                    </ItemTemplate>
                                    <ItemStyle Width="13px" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Page" UniqueName="MenuText">
                                    <ItemTemplate>
                                        <asp:Label ID="lblMenuText" runat="server" Text='<%# Bind("MenuText") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="220px" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Created" UniqueName="CreatedDate">
                                    <ItemTemplate>
                                        <asp:Label ID="lblCreatedDate" runat="server" Text='<%# Bind("CreatedDate") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="164px" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Last Updated" UniqueName="LastUpdatedDate">
                                    <ItemTemplate>
                                        <asp:Label ID="lblLastUpdatedDate" runat="server" Text='<%# Bind("LastUpdatedDate") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="164px" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn UniqueName="EditButton">
                                    <ItemTemplate>
                                        <asp:Button ID="btnEdit" runat="server" CausesValidation="False" CommandArgument='<%# Bind("FileName") %>'
                                            CommandName="Edit" Text="Edit" />
                                    </ItemTemplate>
                                    <ItemStyle Width="60px" HorizontalAlign="Right" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn UniqueName="EditProperties">
                                    <ItemTemplate>
                                        <input type="button" id="btnEditProperties" value="Edit Properties" onclick="radopen('EditPage.aspx?PageId=<%# Eval("ID") %>','EditPageProperties');"
                                            class="adminButton" />
                                    </ItemTemplate>
                                    <ItemStyle Width="60px" HorizontalAlign="Right" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridButtonColumn UniqueName="DeleteButton" ItemStyle-Width="60px" CommandName="Delete"
                                    ConfirmDialogType="RadWindow" ConfirmText="Delete page. Are you sure?" Text="Delete"
                                    ConfirmTitle="Delete Page" ButtonType="PushButton">
                                </telerik:GridButtonColumn>
                            </Columns>
                        </MasterTableView>
                        <FilterMenu EnableTheming="True">
                            <CollapseAnimation Duration="200" Type="OutQuint" />
                        </FilterMenu>
                    </telerik:RadGrid>
                </td>
            </tr>
        </table>
        <cc1:CslaDataSource ID="cdsPageList" runat="server" TypeAssemblyName="" TypeName="Asah.SiteWorx.SiteMap.PageList, Asah"
            TypeSupportsPaging="False" TypeSupportsSorting="False" 
            onselectobject="cdsPageList_SelectObject">
        </cc1:CslaDataSource>
        <telerik:RadWindowManager ID="rwmConfirm" runat="server" Skin="Telerik">
            <Windows>
                <telerik:RadWindow NavigateUrl="~/SiteWorx/CreateNewPage.aspx" Title="Create New Page"
                    VisibleStatusbar="False" runat="server" Modal="true" Width="630px" Height="500px"
                    ID="CreateNewPage" ReloadOnShow="true" Behaviors="Resize, Close, Move" ShowContentDuringLoad="False">
                </telerik:RadWindow>
                <telerik:RadWindow Title="Edit Page Properties" VisibleStatusbar="False" runat="server"
                    Modal="true" Width="630px" Height="500px" ID="EditPageProperties" ReloadOnShow="true"
                    Behaviors="Resize, Close, Move" ShowContentDuringLoad="False">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>

        <script type="text/javascript">
            function toolbarSiteMainClicked(sender, args) {
                var button = args.get_item();
                if (button.get_commandName() == 'CreateNewPage') {
                    radopen(null, button.get_commandName());
                    return false;
                }

            }
            function toolbarSiteMainClicking(sender, args) {
                if (args.get_item().get_value() == "ViewSite") {
                    args.set_cancel(true);
                    window.open('../Default.aspx?preview=true');
                }

            }
        </script>

    </telerik:RadAjaxPanel>
    <telerik:RadAjaxLoadingPanel ID="ralSiteManager" runat="server" Height="75px"
        Width="75px" Style="position: relative; top: -50%; left: 45%;" IsSticky="true">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>
</asp:Content>
